Skip to content

mx erroneously detected inside virtualenv #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
psycoteam opened this issue Apr 27, 2011 · 3 comments
Closed

mx erroneously detected inside virtualenv #53

psycoteam opened this issue Apr 27, 2011 · 3 comments

Comments

@psycoteam
Copy link

Originally submitted by: Anders Pearson

Briefly, the issue is that when installing psycopg2 in a virtualenv that was created with --no-site-packages (in an attempt to be completely independent of the underlying system), psycopg2's setup.py will still find mx and set HAVE_MXDATETIME=1. The compilation and install succeed, but since mx isn't installed in the virtualenv, importing psycopg2 results in an ImportError: can't import mx.DateTime module.

As far as I can tell, this happens because setup.py does

mxincludedir = os.path.join(get_python_inc(plat_specific=1), "mx")

to determine whether mx is available. That will find the mx include directory (eg, /usr/include/python2.6/mx) and it will be able to compile. But this is circumventing the virtualenv and isn't safe behavior when installing into a virtualenv.

I can easily set mxincludedir to a bogus directory to trick it into thinking mx isn't installed anywhere and get it to work, but that doesn't strike me as the best and cleanest solution.

I'm not sure exactly what the best solution is overall, but I'd suggest that one way or another, psycopg2 should only compile in mx.DateTime support when it can both find the mx headers and know that the mx python library will be available.

@dvarrazzo
Copy link
Member

Checking for the importability of mx at build time seems a good solution.

@dvarrazzo
Copy link
Member

Fixed in my devel.

@dvarrazzo
Copy link
Member

I have committed a better fix, to be released soon. mx is now an optional dependency even when the support is built: at runtime, if not found, mx is disabled and psycopg can be imported anyway, only using stdlib datetime objects.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants